﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using NLBS.Entity;
using System.Data;

namespace NLBS.Data
{
    public partial class NHibernateDataProvider : DbProvider
    {
        #region UserGroup

        public override IList<UserGroup> GetUserGroup()
        {
            return CurrentSession.CreateCriteria(typeof(UserGroup)).List<UserGroup>();
        }

        public override int InsertUserGroup(UserGroup group)
        {
            CurrentSession.Save(group);
            return 1;
        }

        public override void UpdateUserGroup(UserGroup group)
        {
            CurrentSession.Update(group);
            CurrentSession.Flush();
        }

        public override UserGroup GetUserGroupByID(int groupID)
        {
            return CurrentSession.Get<UserGroup>(groupID);
        }

        public override void DeleteUserGroup(int groupID)
        {
            CurrentSession.Delete(GetUserGroupByID(groupID));
            CurrentSession.Flush();
        }

        #endregion
    }
}
